{% extends "base.html" %}

{% block content %}
<div class="form-container">
    <h2 class="text-center mb-4">登录</h2>
    <form method="post" class="needs-validation" novalidate>
        {% csrf_token %}
        {% for field in form %}
        <div class="mb-3">
            <label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
            {{ field.errors }}
            <input type="{{ field.field.widget.input_type }}" 
                   name="{{ field.html_name }}"
                   class="form-control {% if field.errors %}is-invalid{% endif %}"
                   id="{{ field.id_for_label }}"
                   {% if field.field.required %}required{% endif %}>
            {% if field.help_text %}
            <div class="form-text">{{ field.help_text }}</div>
            {% endif %}
        </div>
        {% endfor %}
        <div class="d-grid gap-2">
            <button type="submit" class="btn btn-primary">登录</button>
        </div>
    </form>
    <div class="mt-3 text-center">
        <a href="{% url 'password_reset' %}" class="text-decoration-none">忘记密码？</a>
        |
        <a href="{% url 'register' %}" class="text-decoration-none">注册新账号</a>
    </div>
</div>
{% endblock %} 